<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Zend_View_Abstract - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.view.abstract.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.view.abstract.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.view.helpers.html">View Helpers</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.view.html">Zend_View</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.wildfire.html">Zend_Wildfire</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.view.abstract" class="section"><div class="info"><h1 class="title">Zend_View_Abstract</h1></div>
    

    <p class="para">
        <span class="classname">Zend_View_Abstract</span> is the base class on which
        <span class="classname">Zend_View</span> is built; <span class="classname">Zend_View</span> itself simply
        extends it and declares a concrete implementation of the
         <span class="methodname">_run()</span> method (which is invoked by
         <span class="methodname">render()</span>).
    </p>

    <p class="para">
        Many developers find that they want to extend
        <span class="classname">Zend_View_Abstract</span> to add custom functionality, and
        inevitably run into issues with its design, which includes a number of
        private members. This document aims to explain the decision behind the
        design.
    </p>

    <p class="para">
        <span class="classname">Zend_View</span> is something of an anti-templating engine in that
        it uses <acronym class="acronym">PHP</acronym> natively for its templating. As a result, all of
        <acronym class="acronym">PHP</acronym> is available, and view scripts inherit the scope of their calling
        object.
    </p>

    <p class="para">
        It is this latter point that is salient to the design decisions.
        Internally,  <span class="methodname">Zend_View::_run()</span> does the following:
    </p>

    <pre class="programlisting brush: php">
protected function _run()
{
    include func_get_arg(0);
}
</pre>


    <p class="para">
        As such, the view scripts have access to the current object
        (<var class="varname">$this</var>), <em class="emphasis">and any methods or members of that
            object</em>. Since many operations depend on members with
        limited visibility, this poses a problem: the view scripts could
        potentially make calls to such methods or modify critical properties
        directly. Imagine a script overwriting <var class="varname">$_path</var> or
        <var class="varname">$_file</var> inadvertently -- any further calls to
         <span class="methodname">render()</span> or view helpers would break!
    </p>

    <p class="para">
        Fortunately, <acronym class="acronym">PHP</acronym> 5 has an answer to this with its visibility
        declarations: private members are not accessible by objects extending a
        given class. This led to the current design: since
        <span class="classname">Zend_View</span> <em class="emphasis">extends</em>
        <span class="classname">Zend_View_Abstract</span>, view scripts are thus limited to only
        protected or public methods and members of
        <span class="classname">Zend_View_Abstract</span> -- effectively limiting the actions it
        can perform, and allowing us to secure critical areas from abuse by view
        scripts.
    </p>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.view.helpers.html">View Helpers</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.view.html">Zend_View</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.wildfire.html">Zend_Wildfire</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="reference.html">Zend Framework Reference</a></li>
  <li class="header up"><a href="zend.view.html">Zend_View</a></li>
  <li><a href="zend.view.introduction.html">Introduction</a></li>
  <li><a href="zend.view.controllers.html">Controller Scripts</a></li>
  <li><a href="zend.view.scripts.html">View Scripts</a></li>
  <li><a href="zend.view.helpers.html">View Helpers</a></li>
  <li class="active"><a href="zend.view.abstract.html">Zend_View_Abstract</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>